#include <vector>
using namespace std;


// version 1
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target){
        vector<int> ret;
        int left = 0, right = nums.size() - 1;
        while(left < right){
            if(nums[left] + nums[right] > target) right--;
            else if(nums[left] + nums[right] < target) left++;
            else{
                ret = {nums[left], nums[right]};
                return ret;
            }
        }
        return ret;
    }
};